package cn.rulian.base.auth.bo;

import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import cn.rulian.base.common.bo.BaseBo;

import com.fasterxml.jackson.annotation.JsonFormat;


/** 
 * Description: 用户
 */

@Entity
@Table(name = "base_auth_user")
public class User extends BaseBo{

	public static final String DEV="devAdmin"; //开发用户
	
	@Column(length = 50)
	private String username; //用户名
	
	@Column(length = 100)
	private String password; //密码
	
	@Column(length = 50)
	private String name; //姓名
	
	private Boolean enabled; //是否可用
	
	private Integer orderNum; //排序号
	
	@ManyToMany(cascade = CascadeType.PERSIST, fetch = FetchType.LAZY)
	@JoinTable(name="base_auth_role_user",
			joinColumns=@JoinColumn(name="userId", referencedColumnName="id"), 
			inverseJoinColumns=@JoinColumn(name="roleId", referencedColumnName="id"))
	private List<Role> roleList;
	
	@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") 
	private Date addTime; //增加时间
	
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "organ_id")
	private Organ organ; //机构

	private String roleNames; //角色名称（显示用）

	private String organName; //机构名称（显示用）
	
	public String getUsername()
	{
		return username;
	}
	public void setUsername(String username)
	{
		this.username = username;
	}
	public String getPassword()
	{
		return password;
	}
	public void setPassword(String password)
	{
		this.password = password;
	}
	public String getName()
	{
		return name;
	}
	public void setName(String name)
	{
		this.name = name;
	}
	public Boolean getEnabled()
	{
		return enabled;
	}
	public void setEnabled(Boolean enabled)
	{
		this.enabled = enabled;
	}
	public Integer getOrderNum()
	{
		return orderNum;
	}
	public void setOrderNum(Integer orderNum)
	{
		this.orderNum = orderNum;
	}
	public Date getAddTime()
	{
		return addTime;
	}
	public void setAddTime(Date addTime)
	{
		this.addTime = addTime;
	}
	public List<Role> getRoleList()
	{
		return roleList;
	}
	public void setRoleList(List<Role> roleList)
	{
		this.roleList = roleList;
	}
	public Organ getOrgan()
	{
		return organ;
	}
	public void setOrgan(Organ organ)
	{
		this.organ = organ;
	}
	public String getRoleNames()
	{
		return roleNames;
	}
	public void setRoleNames(String roleNames)
	{
		this.roleNames = roleNames;
	}
	public String getOrganName()
	{
		return organName;
	}
	public void setOrganName(String organName)
	{
		this.organName = organName;
	}

	
}